package com.woniuxy.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import java.sql.SQLException;

@Controller
public class TestExceptionController {


    @RequestMapping(value = "/testException1")
    public String testException1()throws Exception{
        //抛出异常
        throw new Exception();
    }
    @RequestMapping(value = "/testException2")
    public String testException2(){
        //模拟异常
        int i=10/0;
        return "success";
    }
    @RequestMapping(value = "/testException3")
    public String testException3()throws Exception{
        try {
            //模拟异常
            int i=10/0;
            return "success";
        } catch (Exception e) {
            throw new SQLException("查找数据失败");
        }

    }
}
